package com.example.chronicdisease.mapper;

import com.example.chronicdisease.dto.CalendarResponseDto;
import com.example.chronicdisease.dto.OrdersMapperDto;
import com.example.chronicdisease.dto.OrdersPageRequestDto;
import com.example.chronicdisease.pojo.Orders;
import com.example.chronicdisease.pojo.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrdersMapper {
    int deleteByPrimaryKey(Integer orderId);

    int insert(Orders record);

    int insertSelective(Orders record);

    Orders selectByPrimaryKey(Integer orderId);

    int updateByPrimaryKeySelective(Orders record);

    int updateByPrimaryKey(Orders record);

    //根据parameList参数，查询30天预约日期中，每一天的已预约人数
    public List<CalendarResponseDto> listOrdersAppointmentNumber(List<OrdersMapperDto> list);

    void updateById(Orders orders);

    @Select("select price from setmeal where smId=#{smId}")
    public Integer getPrice(Integer smId);

    @Select("select name from setmeal where smId=#{smId}")
    public String getSetmealName(Integer smId);

    @Select("select name from hospital where hpId=#{hpId}")
    public String getHospitalName(Integer hpId);

    @Select("select userId, realName, sex from users where userId=#{userId}")
    public Users getUser(String userId);

    @Select("select orderId, userId, orderDate, hpId, smId, state from orders where userId=#{userId} ORDER BY orderDate DESC")
    List<Orders> getUserOrders(String userId);


    //根据条件做预约订单的分页查询
    List<Orders> listOrders(OrdersPageRequestDto request);

    //根据条件查询预约订单总行数
    int getOrdersCount(OrdersPageRequestDto request);

    public Orders getOrdersById(Integer orderId);

    @Update("update orders set state=#{state} where orderId=#{orderId}")
    public int updateOrdersState(Orders orders);
}